extends "../ib.gd"

#根据等级增加属性
func addatt():
	if self.id.find("MAX") != -1:
		att.maxHp += 400
		att.def += 40
		att.mgiDef += 40
		att.dod += 0.05
	else:
		att.maxHp += 150
		att.def += 20
		att.mgiDef += 20
		att.dod += 0.05
	pass
#链接信号和判断是否为最高马
func _connect():
	._connect()
	yield(sys.get_tree().create_timer(0.1),"timeout")
	if !masCha:return
	if self.id.find("MAX") != -1:
		for i in masCha.items:
			if i != self:
				masCha.delItem(i)
		sys.newBaseMsg("提示","一个角色装备满级马之后将无法装备其他装备")
	if !masCha.is_connected("onAddItem",self,"check"):
		#print(1)
		masCha.connect("onAddItem",self,"check")

#判断是否升级及是否只有一匹马
func check(item):
	yield(sys.get_tree().create_timer(0.02),"timeout")
	if item.id.find("horse") != -1 && item != self:
		masCha.delItem(item)
		sys.newBaseMsg("提示","一个角色只能装备一匹马")
	if self.id.find("MAX") != -1 && item != self:
		masCha.delItem(item)
		sys.newBaseMsg("提示","一个角色装备满级马之后将无法装备其他装备")

#进化装备
func upgradeself(item):
	var chose = item.chose
	var c = str(chose)
	var uplist = ["8","17","23","5"]
	var upid = ""
	if chose == 4:
		upid = sys.rndListItem(uplist)
	elif chose == 6:
		upid = sys.rndListItem(["8","5"])
	else:
		for i in uplist:
			if i.find(c) != -1:
				upid = i
				break
	upid = upid + "_Hide"
	if self.id != "i_horse":
		upid = "_MAX"
	upid = self.id + upid
	#self.switchchose(chose)
	var nitem = sys.newItem(upid)
	sys.main.player.addItem(nitem)
	masCha.disconnect("onAddItem",self,"check")
	masCha.addItem(nitem)
	nitem.inheritatt(nitem,self)
	nitem.addatt()
	nitem.switchchose(chose)
	nitem.upinfo()
	self.delself()
	
